package prototype.deepclone;

/**
 * Created by IntelliJ
 * Author:熊磊
 */
public class Client {
    public static void main(String[] args) throws CloneNotSupportedException {
        //方式一
        //DeepProtoType p = new DeepProtoType();
        //p.name = "宋江";
        //p.sheep = new DeepSheep("小白","哈夫曼羊");
        //DeepProtoType clone = (DeepProtoType)p.clone();
        //System.out.println(p);
        //System.out.println(clone);
        //System.out.println(p.sheep.hashCode());
        //System.out.println(clone.sheep.hashCode());
        //方式二
        DeepProtoType p = new DeepProtoType();
        p.name = "宋江";
        p.sheep = new DeepSheep("小白","哈夫曼羊");
        DeepProtoType clone = (DeepProtoType)p.deepClone();
        System.out.println(p);
        System.out.println(clone);
        System.out.println(p.name.hashCode());
        System.out.println(clone.name.hashCode());
        System.out.println(p.sheep.hashCode());
        System.out.println(clone.sheep.hashCode());

        // 基本数据类型和String类型的引用地址不会发生变化
        //DeepSheep deepSheep = new DeepSheep("多莉", "小白羊");
        //DeepSheep clone = (DeepSheep) deepSheep.clone();
        //System.out.println(deepSheep);
        //System.out.println(deepSheep.hashCode());
        //System.out.println(deepSheep.getCloneName().hashCode());
        //System.out.println(deepSheep.getCloneClass().hashCode());
        //System.out.println("==============================");
        //System.out.println(clone);
        //System.out.println(clone.hashCode());
        //System.out.println(clone.getCloneName().hashCode());
        //System.out.println(clone.getCloneClass().hashCode());
    }
}
